//
// Created by mmuee on 2024/4/25.
//

#include "Encrypt.hpp"
#include "mbedtls/ssl.h"
#include "mbedtls/entropy.h"
#include "mbedtls/ctr_drbg.h"
#include "mbedtls/debug.h"

NS_ENC_BEGIN

std::string md5String(const std::string& text)
{
    std::stringstream ss{};
    auto value = text.data();
    uint8_t md5[16] = {0};
    const mbedtls_md_info_t* md_info = mbedtls_md_info_from_string("MD5");
    auto ret = mbedtls_md(md_info, (uint8_t*)value, strlen(value), md5);
    for (unsigned char i : md5)
    {
        printf("%02X", i);
        ss << format_str("%02X", i);
    }
    return ss.str();
}

NS_ENC_END